package com.trace.app.controller;

import com.trace.app.entity.ResponseResult;
import com.trace.app.entity.User;
import com.trace.app.service.LoginService;
import com.trace.app.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class LoginController {

    @Autowired
    private LoginService loginService;

    @Autowired
    private UserService userService;

    @PostMapping("/user/login")
    public ResponseResult login(@RequestBody User user) {
        return loginService.login(user);
    }

    @GetMapping("/user/info")
    public ResponseResult getUserInfo(@RequestParam String username) {
        return loginService.getUserInfo(username);
    }

    @PostMapping("/user/register")
    public ResponseResult register(@RequestBody User user) {
        return loginService.register(user);
    }

    @PostMapping("/user/logout")
    public ResponseResult logout() {
        return loginService.logout();
    }
}
